package com.mck.controller;

import com.mck.entity.FeedBack;
import com.mck.entity.Result;
import com.mck.service.FeedBackService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @version 1.0.0
 * @Author mck
 * @Date 2025/5/4 下午4:53
 * @注释
 */

@RestController
@RequestMapping("/api/public/feedBack")
@Slf4j
public class FeedBackController {

    @Autowired
    private FeedBackService feedBackService;

    /**
     * 添加反馈
     */
    @PostMapping
    public Result addFeedBack(@RequestBody FeedBack feedBack) {
        log.info("添加反馈: {}", feedBack);

        feedBackService.addFeedBack(feedBack);
        return Result.success();

    }


    /**
     * 获取反馈列表
     */
    @GetMapping
    public Result getFeedBackList() {
        log.info("获取反馈列表");

        return Result.success(feedBackService.getFeedBackList());
    }

    /**
     * 获取指定反馈列表
     */
    @PostMapping("/specific")
    public Result getFeedBackList(@RequestBody FeedBack feedBack) {
        log.info("获取反馈列表: {}", feedBack);

        return Result.success(feedBackService.getFeedBackListBySpecific(feedBack));
    }

    /**
     * 删除反馈
     */
    @DeleteMapping
    public Result deleteFeedBack(@RequestBody List<Integer> feedBackId) {
        log.info("删除反馈: {}", feedBackId);

        feedBackService.deleteFeedBack(feedBackId);
        return Result.success();
    }

    /**
     * 更新反馈
     */
    @PutMapping
    public Result updateFeedBack(@RequestBody FeedBack feedBack) {
        log.info("更新反馈: {}", feedBack);

        feedBackService.updateFeedBack(feedBack);
        return Result.success();
    }
}
